#include "queue.hpp"
#include <cstdlib>
int enQueue(queue_t *pqueue, int net_fd)
{
    node_t *pnew = (node_t *)calloc(1, sizeof(node_t));
    pnew->net_fd = net_fd;
    if (pqueue->size == 0)
    {
        pqueue->head = pnew;
        pqueue->end = pnew;
    }
    else
    {
        pqueue->end->pNext = pnew;
        pqueue->end = pnew;
    }
    pqueue->size++;
    return 0;
}
int deQueue(queue_t *pqueue)
{
    if (pqueue->size == 0)
        return -1;
    node_t *p = pqueue->head;
    pqueue->head = p->pNext;
    if (pqueue->size == 1)
    {
        pqueue->end = nullptr;
    }
    pqueue->size--;
    free(p);
    return 0;
}